
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 0795
 * @Author : WangRuoyu 
 * @Date : 2023/9/13 20:09
 */

#include "iostream"

using namespace std;

int main() {
    int n, k;
    scanf("%d %d", &n, &k);

    int a[n];
    int s[n + 1];
    s[0] = 0;

    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        s[i + 1] = s[i] + a[i];
    }

    while (k--) {
        int l, r;
        scanf("%d %d", &l, &r);
        printf("%d\n", s[r] - s[l - 1]);
    }

    return 0;
}